﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ICSharpCode.SharpZipLib.Zip;
using System.IO;
using System.Windows.Forms;

namespace framework.ui
{
    class PackageInpector : TreeView
    {
        public PackageInpector(string path)
        {
            this.Nodes.Add("n1", "Maps");
            this.Nodes.Add("n2", "Mtrls");
            this.Nodes.Add("n3", "Shots");
            ZipEntry entry;
            using (ZipInputStream s = new ZipInputStream(File.OpenRead(path)))
            {
                while ((entry = s.GetNextEntry()) != null)
                {
                    switch(entry.ToString().Split('/')[0].ToCharArray()[1]) {
                        case 'a':
                            if(entry.ToString().ToCharArray()[entry.ToString().Length-1] != 'l')
                                this.Nodes.Find("n1", false)[0].Nodes.Add(new TreeNode(entry.ToString()));
                            break;
                        case 't':
                            this.Nodes.Find("n2", false)[0].Nodes.Add(new TreeNode(entry.ToString()));
                            break;
                        case 'h':
                            this.Nodes.Find("n3", false)[0].Nodes.Add(new TreeNode(entry.ToString()));
                            break;
                    }
                }
            }
        }
    }
}
